-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EBs: Compiled by Default, Controlled at Runtime #4865
Conversation
64f9e2b
to
9aaa9e6
Compare
9aaa9e6
to
e783f39
Compare
This is a good thing to do. Though, is a separate input flag needed? The code can check if |
Thanks, Dave! I was wondering as well, but in the end we have at least three ways to turn it on:
We could a) fix the lack of docs and b) write a helper function that checks them or so? Open to suggestions cc @RemiLehe @roelof-groenewald |
The |
A separate bool ParmParse parameter is not needed unless we want to the one flag to rule them all. If we want a bool variable to be used in the code for convenience, we can add a variable to WarpX class. EB is initialized in WarpX::InitEB. There we can set it to true or false. There are basically two ways to enable EB in WarpXInitEB, (1) |
Thank you for all the ideas!
In ImpactX and also more in WarpX, I try to avoid using global variables in the central sim class and instead use globals from the ParmParser. That way, we do not need to keep them in sync when changing options at runtime (e.g., from Python) and do not need to include a heavy central class everywhere. I would for now write a free standing helper function instead that we can use :) |
Maybe a free function in WarpX like this
|
Note that amrex::IndexSpace has a static member, a vector of amrex::IndexSpace. Somehow this comes into my mind by your mention of global variable. https://en.wiktionary.org/wiki/%E6%88%91%E4%B8%8D%E5%85%A5%E5%9C%B0%E7%8D%84%EF%BC%8C%E8%AA%B0%E5%85%A5%E5%9C%B0%E7%8D%84 |
Note that |
6475eac
to
7031a74
Compare
a974c06
to
24e0c90
Compare
16474c7
to
7e86c97
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Awesome, that resolves the differences 🎉 |
db897d9
to
a2c4511
Compare
EB is not mutually exclusive anymore: we can run non-EB tests with EB compiled in.
a2c4511
to
65928c8
Compare
Correctness is now ensured (see above & passing CI). For performance, I benchmarked 3D runs on my laptop and an exclusive Perlmutter CPU node. From what I can see under the provided noise, there is now no significant performance drawback beyond the noise level for runs that compile with EB but do not use it. Data & NotebookPerlmutter CPU NodeCompiled and ran in local in-memory file system Laptop |
@@ -27,7 +27,7 @@ | |||
# skip lines related to other function arguments | |||
# NOTE: update range call to reflect changes | |||
# in the interface of 'add_warpx_test' | |||
for _ in range(3): | |||
for _ in range(2): # skip over: dims, numprocs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this would be
for _ in range(2): # skip over: dims, numprocs | |
for _ in range(2): # skip over: dims, nprocs |
so that the inline comment matches the correct argument name.
I can include this in one of the CTest follow-up PRs if we do not want to rerun all CI tests again on this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Yes let's put in the follow-up to avoid rerunning the CI here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in #5223
Memory footprint evaluationI ran Development Memory Footprint
PR Memory Footprint
SummaryThe maximums do not change, this looks good to me and we seem to effectively prevent allocating EB-related fields if we do not use them. |
#ifdef AMREX_USE_EB | ||
if(pml_lxfab(i, j, k) <= 0) return; | ||
#endif | ||
if (pml_lxfab && pml_lxfab(i, j, k) <= 0) { return; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename pml_l[xyz]fab
as eb_l[xyz]fab
?
This is because, with the ifdef
not here anymore, it may not be clear to someone reading the code that this is related to embedded boundaries.
(We could also add a comment: // Skip the field update if this gridpoint is inside the embedded boundary
.)
@@ -87,6 +94,9 @@ void ChargeOnEB::ComputeDiags (const int step) | |||
// Judge whether the diags should be done | |||
if (!m_intervals.contains(step+1)) { return; } | |||
|
|||
if (!EB::enabled()) { | |||
throw std::runtime_error("ComputeDiags only works when EBs are enabled at runtime"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw std::runtime_error("ComputeDiags only works when EBs are enabled at runtime"); | |
throw std::runtime_error("ChargeOnEB::ComputeDiags only works when EBs are enabled at runtime"); |
// Skip field push if this cell is fully covered by embedded boundaries | ||
if (lx(i, j, k) <= 0) return; | ||
#endif | ||
if (lx && lx(i, j, k) <= 0) { return; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as further up: we could rename this as eb_lx
to make it clear that it is related to the embedded boundary.
if (electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrame || | ||
electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic) | ||
#ifdef AMREX_USE_EB | ||
// TODO: double check no overhead occurs on "m_eb_enabled == false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh lol, yes we did check that :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for these changes!
Enable embedded boundary compilation by default.
Control via the existing runtime options.
Close #4863
Action Items
Follow-up
We could require that AMReX dependency is always built with
-DAMReX_EB=ON
and with that remove all the safety macrosAMREX_USE_EB
that we currently have to enable that WarpX can also build if AMReX has no EB support. Since EB support in AMReX does not trigger extra dependencies and only moderately increases code complexity for compile (as does that WarpX always requires-DAMReX_PARTICLES=ON
), this might be sensible.To make the compile-time impact more mild, @WeiqunZhang proposed to add another compile-time control to AMReX that disables the compile of a few large linear EB solvers that are not used/needed for WarpX.